package com.smzd.ccms.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.smzd.ccms.domain.Comment;
import com.smzd.ccms.mappers.CommentMapper;
import com.smzd.core.dao.AbstractDao;
import com.smzd.core.mappers.IMapper;
import com.smzd.framework.utils.db.RPage;

@Component
public class CommentDao extends AbstractDao<Comment> {
    @Autowired
    private CommentMapper mapper;

    @Override
    protected IMapper<Comment> getMapper() {
        return mapper;
    }

    public RPage<Comment> getCommentsForArticle(RPage<Comment> page) {
        preparePage(page);
        List<Comment> elems = mapper.getCommentsForArticle(page);
        page.setElems(elems);
        int totalCount = mapper.getCommentsContForArticle(page);
        page.setTotalCount(totalCount);
        completePage(page);
        return page;
    }

	public void updateCommentStatus(Comment comment) {
		mapper.updateCommentStatus(comment);
	}

	public List<Comment> getCommentsForFirstArticle(Integer chId) {
		return mapper.getCommentsForFirstArticle(chId);
	}
}